using Admin2025.Application.Services;
using Admin2025.Application.Contracts.Configuration;
using Admin2025.Application.Configurations;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;


namespace Admin2025.Application;

public static class ServicesCollectionExtension
{
  public static IServiceCollection AddApplication(this IServiceCollection services, IConfiguration config)
  {
    //注册MediatR
    services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(ServiceCollectionExtensions).Assembly));

    services.AddScoped<AuthService>();

    services.AddScoped<IAppUserService, AppUserService>();
    services.AddScoped<IAppRoleService, AppRoleService>();
    services.AddScoped<IAppPermissionService, AppPermissionService>();
    services.AddScoped<IFileUploadService, FileUploadService>();

    services.Configure<JwtSettings>(config.GetSection("Jwt"));
    services.Configure<FileUploadSettings>(config.GetSection("FileUPload"));
    return services;
  }
}